package com.wy.projectssj.controller;

import com.wy.projectssj.domain.Permission;
import com.wy.projectssj.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @Author: wy
 * @Date:2019/8/30 13:17
 */
@Controller
@RequestMapping("/permission")
public class PermissionController {
     @Autowired
     private PermissionService permissionService;
    @RequestMapping("/findAll")
    public String findAll(Model model){
        List<Permission> list = permissionService.findAll();
           model.addAttribute("permissionList",list);
           return "permission-list";
    }
    @RequestMapping("/addOne")
    public String addOne(){
        return "permission-add";
    }

         @RequestMapping("/save")
      public String save(Permission permission){
             int save = permissionService.save(permission);
             return "redirect:/permission/findAll";
         }

          @RequestMapping("/delete")
         public String delete(String[] ids){
                   //先删除从表中的数据
             int delete = permissionService.delete(ids);
             return "redirect:/permission/findAll";
    }
}
